<template>
    <div class="wfull flex">
        <div class="flex-1">
            <a-range-picker size="small" style="width: 238px"
                @change="rangeDatePickerChange"
                v-model:value="item.value"
                :valueFormat="item.FValScope == 'createTime' ? 'YYYY-MM-DD' : item.FValScope"
                :format="item.FValScope == 'createTime' ? 'YYYY-MM-DD' : item.FValScope"
                :picker="{
                    'YYYY': 'year',
                    'YYYY-MM': 'month',
                    'YYYY-MM-DD': 'date',
                    'createTime': 'date',
                    'YYYY-MM-DD HH:mm': 'date',
                    'YYYY-MM-DD HH:mm:ss': 'date',
                }[item.FValScope]"
                :show-time="item.FValScope.indexOf('HH') > -1 ? { format: item.FValScope.slice(11) } : false"
                :disabled="disabled" allowClear :bordered="false" />
        </div>
        <div style="width: 90px;">
            <lo-select class="w100"
                v-if="item.FValScope == 'YYYY-MM-DD'"
                v-model:value="fastRangeKey"
                @change="fastRangeDatePickerChange"
                placeholder="请选择" :options="[
                    { value: 'today', label: '今天' },
                    { value: 'yesterday', label: '昨天' },
                    { value: 'week', label: '本周' },
                    { value: 'lastWeek', label: '上周' },
                    { value: 'month', label: '本月' },
                    { value: 'lastMonth', label: '上月' },
                    { value: 'quarter', label: '本季度' },
                    { value: 'lastQuarter', label: '上季度' },
                    { value: 'year', label: '本年' },
                ]" noborder noClear></lo-select>
        </div>
    </div>
</template>

<script setup lang="jsx">
import {ref, reactive } from "vue"


function rangeDatePickerChange(e) {
    let dateMap = getRangeMap()
    console.log(e);
    if (e) {
        fastRangeKey.value = Object.keys(dateMap).find(key => dateMap[key].join(',') == e.join(',')) || ''
    } else {
        fastRangeKey.value = ''
    }
    pressEnter()
}

const fastRangeKey = ref('')
function fastRangeDatePickerChange(e) {
    let date = getRangeMap(e)
    props.item.value = date
    pressEnter()
    console.log(date);
}

</script>
<style lang="less" scoped>

</style>
